
// Copyright (c) 2002 HTHK
package admin.system.func;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;

import com.ffpc.servlet.*;
import com.ffpc.sql.*;
import com.ffpc.struts.StrutsMessage;

/**
 * A Class class.
 * <P>
 * @author HTHK
 */
public class FuncSearch
  extends DBServlet {

  @Override
protected String perform(  HttpServletRequest request,
                             HttpServletResponse response,
                             StrutsMessage message)
    throws  ServletException,
            IOException,
            SQLException,
            DataException,
            Exception
  {
      FuncBean func = FuncProcess.createBean();
      func.setFunc_id(request.getParameter("func_id"));
      func.setFunc_name(request.getParameter("func_name"));
      func.setParent_id(request.getParameter("parent_id"));
      func.setUrl(request.getParameter("url"));
      func.setDivision(request.getParameter("division"));
      func.setSequence(request.getParameter("sequence"));
      FuncBean[] funcs = FuncProcess.find(this.getConnection(),func);
      if (funcs==null || funcs.length==0)
      {
          message.setMessage("No record, please input another criteria.");
          return "system/FuncSearch.jsp";
      }
      else if (funcs.length==1)
      {
          request.setAttribute("func",funcs[0]);
          return "system/Func.jsp?formAction=Update";
      }
      else
      {
          request.setAttribute("funcs",funcs);
          return "system/FuncList.jsp";
      }
  }
}


